class MsuiDataGridItemModel {
  constructor({
    key,
    title,
    dataIndex,
    align = 'center'
  } = {}) {
    this.key = key
    this.title = title
    this.dataIndex = dataIndex
    this.align = align
  }
  setBind(data) {
    for(let key in data) {
      this[key] = data[key]
    }
    return this
  }
  formatter(formatters) {
    this.formatters = (value) => {
      if (this.data instanceof Promise) {
        this.data.then(() => {
          this.formatters = formatters
        })
        return value
      } else {
        this.formatters = formatters
      }
    }
    return this
  }
  formatterData({ data }) {
    if (data instanceof Promise) {
      data.then((data) => {
        this.data = data
      })
      this.data = data
    } else if (data.length > 0) {
      this.data = data
    }
    return this
  }
}

export default MsuiDataGridItemModel
